﻿Imports System.Collections.Generic
Imports System.Linq
Imports System.Data
Imports System.Text
Imports System.Windows.Forms
Imports DevComponents.DotNetBar.Controls
Imports DevComponents.Editors.DateTimeAdv
Imports DoAnQuanLyBanHang1065043_1065007.DoAnQuanLyBanHang.DTO
Imports DoAnQuanLyBanHang1065043_1065007.DoAnQuanLyBanHang.General
Imports DoAnQuanLyBanHang1065043_1065007.DoAnQuanLyBanHang.BUSS

Namespace DoAnQuanLyBanHang.DAO
    Public Class NhaCungCapCtrl
        Private m_NhaCungCapData As New NhaCungCapData()
        Private m_NhaCungCapInfo As New NhaCungCapInfo()
        Public Sub HienThiComboBox(cbx As ComboBox)
            Dim m_DT As DataTable = m_NhaCungCapData.LayNhaCungCap()
            cbx.DataSource = m_DT
            cbx.DisplayMember = "TenNCC"

            cbx.ValueMember = "MaNCC"


        End Sub

#Region "Hien thi ComboBox trong DataGridView"
        Public Sub HienThiDataGridViewComboBoxColumn(cmbColumn As DataGridViewComboBoxColumn)
            cmbColumn.DataSource = m_NhaCungCapData.LayNhaCungCap()
            cmbColumn.DisplayMember = "TenNCC"
            cmbColumn.ValueMember = "MaNCC"
            cmbColumn.DataPropertyName = "MaNCC"
            cmbColumn.HeaderText = "Tên nhà cung cấp"
        End Sub
#End Region

#Region "hien thi"
        Public Sub HienThi(Dgv As DataGridView, bvn As BindingNavigator)
            Dim bs As New BindingSource()

            bs.DataSource = m_NhaCungCapData.LayNhaCungCap()
            bvn.BindingSource = bs
            Dgv.DataSource = bs
        End Sub

        Public Sub HienThi(dGV As DataGridViewX, bN As BindingNavigator, txtMaNCC As TextBoxX, txtTenNhaCC As TextBoxX, txtEmail As TextBoxX, txtDiaChi As TextBoxX, _
         txtFax As TextBoxX, txtGhiChu As TextBoxX, txtDienThoai As TextBoxX)
            Dim bS As New BindingSource()
            bS.DataSource = m_NhaCungCapData.LayNhaCungCap()

            txtMaNCC.DataBindings.Clear()
            txtMaNCC.DataBindings.Add("Text", bS, "MaNCC")

            txtTenNhaCC.DataBindings.Clear()
            txtTenNhaCC.DataBindings.Add("Text", bS, "TenNCC")

            txtEmail.DataBindings.Clear()
            txtEmail.DataBindings.Add("Text", bS, "Email")

            txtDiaChi.DataBindings.Clear()
            txtDiaChi.DataBindings.Add("Text", bS, "DiaChi")

            txtFax.DataBindings.Clear()
            txtFax.DataBindings.Add("Text", bS, "Fax")


            txtGhiChu.DataBindings.Clear()
            txtGhiChu.DataBindings.Add("Text", bS, "GhiChu")

            txtDienThoai.DataBindings.Clear()
            txtDienThoai.DataBindings.Add("Text", bS, "DienThoai")

            bN.BindingSource = bS
            dGV.DataSource = bS
        End Sub
#End Region

#Region "Them moi"
        Public Function ThemDongMoi() As DataRow
            Return m_NhaCungCapData.ThemDongMoi()
        End Function
        Public Sub ThemMoi(m_Row As DataRow)
            m_NhaCungCapData.ThemNhaCungCap(m_Row)
        End Sub
#End Region

#Region "Luu"
        Public Function LuuNhaCungCap() As Boolean
            Return m_NhaCungCapData.LuuNhaCungCap()
        End Function

        Public Sub LuuNhaCungCap(mancc As [String], tenncc As [String], dienthoai As [String], fax As [String], email As [String], diachi As [String], _
         ghichu As [String])
            m_NhaCungCapData.LuuNhaCungCap(mancc, tenncc, dienthoai, fax, email, diachi, _
             ghichu)
        End Sub
#End Region

#Region "Sửa"

        Public Sub SuaNhaCungCap(mancc As [String], tenncc As [String], dienthoai As [String], fax As [String], email As [String], diachi As [String], _
         ghichu As [String])
            m_NhaCungCapData.SuaNhaCungCap(mancc, tenncc, dienthoai, fax, email, diachi, _
             ghichu)
        End Sub
#End Region
#Region "Xóa"
        Public Sub XoaNhaCungCap(mancc As [String])
            m_NhaCungCapData.XoaNhaCungCap(mancc)
        End Sub
#End Region
#Region "tim kiem"
        Public Sub TimKiemTheoMa(m_MaNV As [String])
            m_NhaCungCapData.TimKiemTheoMa(m_MaNV)
        End Sub

        Public Sub TiemKiemTheoTen(m_HoTen As [String])
            m_NhaCungCapData.TimKiemTheoTen(m_HoTen)
        End Sub
#End Region

    End Class
End Namespace
